<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var student = {
      name:"田梦",
      age:23,
      sex:"女",
      score:{
        english:75,
        math:81,
        chinese:88
      },
      star:["岳云鹏","郭德纲","郭麒麟"]
    }
    function clone(obj,newObj){
      var newObj = newObj || {};
      for(var i in obj){
        if(typeof obj[i] == 'object'){
　　　　　　newObj[i] = (obj[i].constructor === Array) ? [] : {}
　　　　　　setObject(obj[i],newObj[i]); // 递归函数
  　　　　}else{
  　　　　　　newObj[i] = obj[i]
  　　　}
      }
    }
  </script>
</body>
</html>